//
//  PurpleView.m
//  02-hittext练习1
//
//  Created by J on 16/2/20.
//  Copyright © 2016年 J. All rights reserved.
//

#import "PurpleView.h"
@interface PurpleView()

@property (weak, nonatomic) IBOutlet UIButton *blueButton;



@end
@implementation PurpleView

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
//    NSLog(@"%s",__FUNCTION__);
}

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event{
    
    //当前坐标系上的点转换到按钮上的点
    CGPoint hitPoint = [self convertPoint:point toView:self.blueButton];
    
    
    //判断点在不在按钮上
    if ([self.blueButton pointInside:hitPoint withEvent:event]) {
        
        return self.blueButton;//返回按钮
    }else{
        return [super hitTest:point withEvent:event];

    }
//    return nil;
    
//    NSLog(@"%s",__FUNCTION__);
//    
    return [super hitTest:point withEvent:event];
}


@end
